class Test(IViewPortScriptQuery):
    def query(self, fd_code: str, parameters: dict) -> Page:
        pageSize = parameters.get('pageSize', 10)
        page = parameters.get('page', 1)
        start = (page - 1) * pageSize
        dangertrip = parameters.get('dangertrip')
        incollege = parameters.get('incollege')
        name = parameters.get('name', '')
        filter_condition = f"where name like '%{name}%'"
        if dangertrip is not None:
            filter_condition += f" and dangertrip={dangertrip}"
        if incollege is not None:
            filter_condition += f" and incollege={incollege}"
        sql = """
        select number, name, sex, dept, dangertrip, incollege from stustatusdaily
        {}
        limit {}, {}
        """.format(filter_condition, start, pageSize)
        result = FactDatasourceClient.query(fd_code, sql)
        return Page(pageNum=page, pageSize=pageSize, list=result)


class Test(IViewPortScriptQuery):
    def query(self, fd_code: str, parameters: dict) -> Page:
        pageSize = parameters.get('pageSize', 10)
        page = parameters.get('page', 1)
        start = (page - 1) * pageSize
        dangertrip = parameters.get('dangertrip')
        incollege = parameters.get('incollege')
        name = parameters.get('name', '')
        filter_condition = f"where name like '%{name}%'"
        if dangertrip is not None:
            filter_condition += f" and dangertrip={dangertrip}"
        if incollege is not None:
            filter_condition += f" and incollege={incollege}"
        sql = """
        select * from stustatusdaily
        {}
        limit {}, {}
        """.format(filter_condition, start, pageSize)
        result = FactDatasourceClient.query(fd_code, sql)
        count_sql = """
        select count(number) as total from stustatusdaily
        {}
        """.format(filter_condition)
        count_result = FactDatasourceClient.query(fd_code, count_sql)
        total = count_result[0].total
        return Page(pageNum=page, pageSize=pageSize, total=total, list=result)


class TeacherInfo(IViewPortScriptQuery):
    """老师首页信息"""

    def query(self, fd_code: str, parameters: dict) -> Page:
        pageSize = parameters.get('pageSize', 10)
        page = parameters.get('page', 1)
        start = (page - 1) * pageSize
        in_danger = parameters.get('in_danger')
        in_school = parameters.get('in_school')
        username = parameters.get('username', '')
        filter_condition = f"where username like '%{username}%'"
        if in_danger is not None:
            filter_condition += f" and in_danger={in_danger}"
        if in_school is not None:
            filter_condition += f" and in_school={in_school}"
        sql = """
        select usercode, username, sex, dept, age,  in_danger, in_school FROM teacherhomepage
        {}
        limit {}, {}
        """.format(filter_condition, start, pageSize)
        result = FactDatasourceClient.query(fd_code, sql)

        count_sql = """
                select count(usercode) as total from teacherhomepage
                {}
                """.format(filter_condition)
        count_result = FactDatasourceClient.query(fd_code, count_sql)
        total = count_result[0].total
        return Page(pageNum=page, pageSize=pageSize, total=total, list=result)


self.task_logger.log(output_datas)